package org.wattdepot.cli.command;

import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import static org.junit.Assert.assertEquals;

/**
 * Help command test case.
 * 
 * @author Edward Meyer, Bao Huy Ung
 * 
 */
public class TestHelpCommand {

  /**
   * Tests if the HelpCommand class returns correct help menu.
   */
  @Test
  public void testHelpCommand() {

    // Create a list to pass into HelpCommand.
    List<String> args = new ArrayList<String>();
    args.add("help");

    // A string of the most up-to-date help commands.
    String knownOutput = "";

    knownOutput += "help \n";
    knownOutput += "  This message.\n";
    knownOutput += "quit\n";
    knownOutput += "  Exits the system.\n";
    knownOutput += "sources\n";
    knownOutput +=
        "  Prints a table summarizing the public sources " + "in the system, one per line.\n";
    knownOutput += "summary {source} \n";
    knownOutput += "  Prints information about a single source.\n";
    knownOutput += "sensordata {source} timestamp {timestamp}\n";
    knownOutput += "  Prints information about a single sensor data instance.\n";
    knownOutput += "dailysensordata {source} day {day}\n";
    knownOutput +=
        "  Prints a table listing all of the sensor" + " data instances for the specified day.\n";
    knownOutput += "power {source} timestamp {timestamp}\n";
    knownOutput += "  Prints the power generated by the source at the given timestamp.\n";
    knownOutput +=
        "powerstats {source} day {day} sampling-interval"
            + " {minutes} statistic {max|min|average}\n";
    knownOutput +=
        "  Returns the maximum, minimum, or average power"
            + " generated by the source for the day.\n";
    knownOutput += "total [carbon|energy] {source} day {day} sampling-interval {minutes}\n";
    knownOutput +=
        "  Returns the total amount of carbon (or energy)"
            + " emitted by this source for the given day.\n";
    knownOutput +=
        "chart power [generated|consumed] {source} {startday}"
            + " {endday} sampling-interval {minutes} file {file}\n";
    knownOutput +=
        "  Writes out an html file that will display a"
            + " chart illustrating the power for the source over the interval.\n";
    knownOutput +=
        "fueltypes {source}\n" + "  Returns a table of fuelds associated with this source.\n";
    knownOutput +=
        "totalpower {source} {timestamp} fueltype {fueltype}\n"
            + "  Returns the total power generated by the given fuel type.\n";
    knownOutput +=
        "carboncontent {source} {timestamp} sampling-interval {interval}\n"
            + "  Returns the total carbon that would be emitted by that source over "
            + "an hour at the rate occurring as of the timestamp.";

    HelpCommand help = new HelpCommand();
    String commandOutput = help.doCommand(args);

    System.out.println("Asserting help menu is correct...");
    assertEquals("Checking help menu is correct.", knownOutput, commandOutput);

  }

}
